package com.yj.config.mybatis.pagination;

import lombok.Data;

import java.util.List;

/**
 * Copyright 2017 (C) Yunjian-VC
 * Created on : 2017/12/8
 * Author     : Unbelievable9
 **/
@Data
public class Page<T> {

    private Integer pageNumber = 1;

    private Integer pageSize = 20;

    private Integer totalItem;

    private Integer totalPage;

    private List<T> pageResult;

    private Page() {

    }

    public static Page createInstance() {
        return new Page();
    }

    public void setTotalItem(int totalItem) {
        this.totalItem = totalItem;
        int totalPage = totalItem % pageSize == 0 ? totalItem / pageSize : totalItem / pageSize + 1;
        this.setTotalPage(totalPage);
    }
}
